package com.ygo.feihua;
import android.content.*;
import android.os.*;
import android.support.v7.app.*;
import android.support.v7.widget.*;
import android.view.*;
import android.view.View.*;
import android.widget.*;
import com.ygo.feihua.util.*;
import java.util.*;

import android.support.v7.widget.Toolbar;
import com.ygo.feihua.service.*;

public class ShezhiKaiguan extends AppCompatActivity
{

	private Switch kg_zygx,kg_wzsc;
	private RelativeLayout kg_browser;
	
	private Gongju gj;
	private DialogUtils du;
	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		// TODO: Implement this method
		super.onCreate(savedInstanceState);
		setContentView(R.layout.shezhi_kaiguan);
		
			
		kg_zygx=(Switch) findViewById(R.id.kg_zygx);
		kg_wzsc=(Switch) findViewById(R.id.kg_wzsc);
		kg_browser=(RelativeLayout) findViewById(R.id.kg_browser);
		gj=Gongju.getdx(this);
		du=DialogUtils.getdx(this);
		gj.cshToolbar((Toolbar) findViewById(R.id.toolbar),"各种开关");
		
		final SharedPreferences setting=SharedPreferenceUtil.getShareKaiguan();
		
		kg_browser.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View p1)
				{
					List<String> ls1=new ArrayList<String>();
					ls1.add("内置浏览器");
					ls1.add("外置浏览器");
					int c=0;
					switch(SharedPreferenceUtil.getBrowserIntent()){
						case SharedPreferenceUtil.TYPE_BUILT_IN:
							c=0;
							break;
						case SharedPreferenceUtil.TYPE_EXTERNAL:
							c=1;
							break;
					}
					DialogUtils.Select se= du.dialogRadio("网页打开方式",ls1,c);

					se.setOnRadioListener(new DialogUtils.OnRadioListener(){

							@Override
							public void onRadio(List<String> data, int position)
							{

								int c=SharedPreferenceUtil.TYPE_BUILT_IN;
								switch(position){
									case 0:
										c=SharedPreferenceUtil.TYPE_BUILT_IN;
										break;
									case 1:
										c=SharedPreferenceUtil.TYPE_EXTERNAL;
										break;
								}
								
								SharedPreferenceUtil.getShareType().edit().putInt("intent_browser",c).commit();
								

								// TODO: Implement this method
							}
						});
					
					// TODO: Implement this method
				}
			});
		
		
		if(SharedPreferenceUtil.getKgZyToast()){
			kg_zygx.setChecked(true);
		}else{
			kg_zygx.setChecked(false);
		}
		if(SharedPreferenceUtil.getKgUploadLocation()){
			kg_wzsc.setChecked(true);
		}else{
			kg_wzsc.setChecked(false);
		}
		kg_wzsc.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){

				@Override
				public void onCheckedChanged(CompoundButton p1, boolean p2)
				{
					if(p2){
						setting.edit().putBoolean("scwz",true).commit();
						startService(new Intent(ShezhiKaiguan.this,ServiceMap.class));
					}else{
						setting.edit().putBoolean("scwz",false).commit();
						stopService(new Intent(ShezhiKaiguan.this,ServiceMap.class));
					}
					// TODO: Implement this method
				}
			});
		kg_zygx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){

				@Override
				public void onCheckedChanged(CompoundButton p1, boolean p2)
				{
					if(p2){
						setting.edit().putBoolean("zygx",true).commit();
					}else{
						setting.edit().putBoolean("zygx",false).commit();
					}
					// TODO: Implement this method
				}
			});
	}
}
